#include <iostream>

template<class T1, class T2>
void handler(T1 a, T2 b)
{
   std::cout << "void handler()" << std::endl;
   return;
}

// 函数模板全特化 此时一般直接定义
template<>
void handler<int, double>(int a, double b)
{
   std::cout << "void handler<int, double>()" << std::endl;
   return;
}
// 函数模板偏特化 不被允许  err
//template<class T1>
//void handler<T1, int>(T1 a, int b)
//{
//   std::cout << "void handler<T1, double>()" << std::endl;
//   return;
//}

// 使用functor间接实现函数模板偏特化
template<class T1, class T2>
class handler_functor
{
public:
   handler_functor(T1 a, T2 b)
      :_a(a), _b(b)
   {}

   void operator()()
   {
      // do something with _a and _b...
      std::cout << "void operator()()" << std::endl;
      return;
   }

private:
   T1 _a;
   T2 _b;
};

template<class T1>
class handler_functor<T1, double>
{
public:
   handler_functor(T1 a, double b)
      :_a(a), _b(b)
   {}

   void operator()()
   {
      // do something with _a and _b...
      std::cout << "void operator()()" << std::endl;
      return;
   }

private:
   T1 _a;
   double _b;
};

template<class T1, class T2>
class Widget
{ };
// 类模板全特化
template<>
class Widget<int, double>
{ };
// 类模板偏特化
template<class T1>
class Widget<T1, double>
{ };
